<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>从 GD 文件或 URL 新建一图像</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.imagecreatefromgd2part.html">« imagecreatefromgd2part</a></li>
      <li style="float: right;"><a href="function.imagecreatefromgif.html">imagecreatefromgif »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.image.html">GD 和图像处理 函数</a></li>
    <li>从 GD 文件或 URL 新建一图像</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.imagecreatefromgd" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">imagecreatefromgd</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecreatefromgd</span> &mdash; <span class="dc-title">从 GD 文件或 URL 新建一图像</span></p>

   </div>
 <div class="refsect1 description" id="refsect1-function.imagecreatefromgd-description">
  <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="methodname"><strong>imagecreatefromgd</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>): <span class="type">resource</span></div>

    <p class="para rdfs-comment">
    从 GD 文件或 URL 新建一图像。
  </p>
    <div class="tip"><strong class="tip">小技巧</strong><p class="simpara">如已启用<a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">fopen 包装器</a>，在此函数中， URL 可作为文件名。关于如何指定文件名详见 <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>。各种
wapper 的不同功能请参见 <a href="wrappers.html" class="xref">支持的协议和封装协议</a>，注意其用法及其可提供的预定义变量。</p></div>
   </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecreatefromgd-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">filename</code></dt>

     <dd>

      <p class="para">
       GD 文件的路径。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecreatefromgd-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">成功后返回图象对象,失败后返回 <strong><code>false</code></strong>。</p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imagecreatefromgd-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2651">
    <p><strong>示例 #1 <span class="function"><strong>imagecreatefromgd()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Load&nbsp;the&nbsp;gd&nbsp;image<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;@</span><span style="color: #0000BB">imagecreatefromgd</span><span style="color: #007700">(</span><span style="color: #DD0000">'./test.gd'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Test&nbsp;if&nbsp;the&nbsp;image&nbsp;was&nbsp;loaded<br /></span><span style="color: #007700">if(!</span><span style="color: #0000BB">is_resource</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">))<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'Unable&nbsp;to&nbsp;load&nbsp;gd&nbsp;image!'</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Do&nbsp;image&nbsp;operations&nbsp;here<br /><br />//&nbsp;Save&nbsp;the&nbsp;image<br /></span><span style="color: #0000BB">imagegd</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'./test_updated.gd'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 notes" id="refsect1-function.imagecreatefromgd-notes">
  <h3 class="title">注释</h3>
  
 </div>

  </div></div></div></body></html>